import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.extras 0.1 as PlasmaExtras


Content {
    id: buttonContent
    
    property variant svg
    // property alias svg: icon.svg  // TODO: understand why this is evil
    property alias name: icon.elementId
    
    desiredWidth: icon.naturalSize.width
    desiredHeight: icon.naturalSize.height
    
    signal clicked
        
    MouseArea {
        id: mouseArea
        
        acceptedButtons: Qt.LeftButton
        hoverEnabled: true
        preventStealing: true
        
        anchors.fill: parent
        
        onClicked: buttonContent.clicked()
        
        onPressed: PlasmaExtras.PressedAnimation {
            targetItem: icon
        }
        
        onReleased: PlasmaExtras.ReleasedAnimation {
            targetItem: icon
        }
        
        onEntered: NumberAnimation {
            target:icon
            property: "opacity"
            to: 0.8
            duration: 100
        }
        
        onExited: NumberAnimation {
            target:icon
            property: "opacity"
            to: 1
            duration: 100
        }
    }
    
    PlasmaCore.SvgItem{
        id: icon
        
        svg: parent.svg
        
        width: Math.min(parent.height, parent.width)
        height: width
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
        
    }
}
